package it.koutifaris.travianmap.view.mainview;

import it.koutifaris.travianmap.R;
import it.koutifaris.travianmap.communication.mapdownloader.DownloadProgressHandler;
import it.koutifaris.travianmap.context.HasApplicationContex;
import it.koutifaris.travianmap.dal.TravianServerService.TravianServer;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Toast;

public class DownloadOnClickListener extends HasApplicationContex implements OnClickListener {

	private final TravianServer server;
	private final DownloadProgressHandler downloadProgressHandler;

	public DownloadOnClickListener(
			TravianServer server,
			DownloadProgressHandler downloadProgressHandler) {

		this.server = server;
		this.downloadProgressHandler = downloadProgressHandler;
	}

	@Override
	public void onClick(View view) {
		Toast.makeText(getActivity(), R.string.maplist_downloading, Toast.LENGTH_SHORT).show();
		getTravianMapContext().getMapDownloader(server.getServerId()).download(server, downloadProgressHandler);
	}

}